﻿//********************************************************************************//
//创建日期：<创建日期，2016-09-18>
//创建作者：<郭登杰，guodengjie@shanghai3h.com>
//功能说明：报表预览打印
//********************************************************************************//

using System;
using System.Web.UI;
using Entity;
using Web.Class;

namespace Web.Pages.YongShui._15.BaoBiaoGL
{
    public partial class BaoBiaoView : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                WebReport1.Prepare();
        }

        protected void WebReport1_StartReport(object sender, EventArgs e)
        {
            //获取报表ID
            var baobiaoid = int.Parse(Request.QueryString["baobiaoid"]);
            //获取偏移参数
            var x = string.IsNullOrEmpty(Request.QueryString["x"]) ? 0 : float.Parse(Request.QueryString["x"]);
            var y = string.IsNullOrEmpty(Request.QueryString["y"]) ? 0 : float.Parse(Request.QueryString["y"]);
            var options = new PrintOptions(x, y);
            //获取传递过来的参数列表
            var csList = new DALBaoBiaoCS().GetByBaoBiaoId(baobiaoid);
            var csArr = Request.QueryString["baobiaocs"].Split('|');
            for (var i = 0; i < csList.Count; i++)
            for (var j = 0; j < csArr.Length; j++)
                if (csArr[j].Split(':')[0] == csList[i].S_CANSHU)
                {
                    csList[i].S_CANSHUZ = csArr[j].Split(':')[1];
                    break;
                }

            //实例化报表
            var myreport = new MyReportWeb(eReportOpenType.Preview, csList, null, WebReport1);
            //初始化报表
            var rs = myreport.Init(baobiaoid, null, LoginInfo.CurrentUser.UserID.ToString());
            if (!rs.IsSuccess)
            {
                PageTools.AlertMsg(this, rs.ReturnMsg);
                return;
            }
            //加载模版
            rs = myreport.LoadTemplate();
            if (!rs.IsSuccess)
            {
                PageTools.AlertMsg(this, rs.ReturnMsg);
                return;
            }
            //加载数据
            rs = myreport.LoadData();
            if (!rs.IsSuccess)
            {
                PageTools.AlertMsg(this, rs.ReturnMsg);
                return;
            }
            myreport.LoadXY();
        }
    }
}